<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加问题</title>
</head>
<body>
    <form id="form" action="/api/question/add" method="post">
        <label for="question">question:</label><input id="question" name="question" type="text" placeholder="input question"><br>
        <label for="answer"></label><input hidden name="answer" id="answer" type="text" placeholder="input answer"><br>
        <label for="ans1">选项一:</label><input name="ans1" id="ans1" type="text" placeholder="input answer1"><br>
        <label for="ans2">选项二:</label><input name="ans2" type="text" id="ans2" placeholder="input answer2"><br>
        <label for="ans3">选项三:</label><input name="ans3" type="text" id="ans3" placeholder="input answer3"><br>
        <label for="ans4">选项四:</label><input name="ans4" type="text" id="ans4" placeholder="input answer4"><br>
        <label for="rightans">正确的选项：</label><input id="rightans" name="rightans" type="text" placeholder="input rightans"><br>
        <br><br>
        <label for="category">问题类别：</label><input id="category" name="category" type="text" placeholder="常识判断"><br>
        <label for="difficulty">难度：</label><input id="difficulty" name="difficulty" type="number" value="0"><br>
        <input type="button" id="smart" value="Smart Submit" onclick="beforeSubmit()">
        <button  type="submit" id="btnSubmit" hidden>submit</button>
    </form>
    <div id="message"></div>
</body>
<script>
    function beforeSubmit() {
        var postURL = "/api/question/add";
        var ans1 = document.getElementById("ans1").value;
        var ans2 = document.getElementById("ans2").value;
        var ans3 = document.getElementById("ans3").value;
        var ans4 = document.getElementById("ans4").value;

        var ansList = [ans1,ans2,ans3,ans4];
        document.getElementById("answer").value= ansList.join("|");
        document.getElementById("btnSubmit").click();

        document.getElementById("question").value="";
        document.getElementById("ans1").value="";
        document.getElementById("ans2").value="";
        document.getElementById("ans3").value="";
        document.getElementById("ans4").value="";
        document.getElementById("rightans").value="";
    }
</script>
</html>